//
//  GDPresentationController.m
//  美团试验 (自己)
//
//  Created by 热带雨林 on 17/2/14.
//  Copyright © 2017年 热带雨林. All rights reserved.
//

#import "GDPresentationController.h"
#import "Masonry.h"

@implementation GDPresentationController
//将要布局子控价
- (void)containerViewWillLayoutSubviews{
    [super containerViewWillLayoutSubviews];
    //包容视图
    UIView *containerView = self.containerView;
    //第二个视图
    UIView *presenterView = self.presentedView;
    //手动的添加
    [containerView addSubview:presenterView];
    [presenterView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(containerView);
        make.height.mas_equalTo(230);
    }];
    //添加一层蒙板
    UIView *dimView = [[UIView alloc]init];
    dimView.backgroundColor = [UIColor blackColor];
    dimView.alpha = 0.3;
    
    [containerView insertSubview:dimView atIndex:0];
    
    [dimView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.bottom.equalTo(containerView);
    }];
    
    //添加一个点击手势，回到订单界面
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)];
    //在蒙板添加手势
    [dimView addGestureRecognizer:tap];
    
}

- (void)tap:(UITapGestureRecognizer *)sender{
    
    [self.presentedViewController dismissViewControllerAnimated:YES completion:nil];

}

@end
